home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8749 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.0 KB  |  83 lines

  1. Path: dsi.unimi.it!moreld
  2. From: moreld@dsi.unimi.it (~ZIO BUDDA~)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: How to write header file ?
  5. Date: 26 Feb 1996 15:03:30 GMT
  6. Organization: Computer Science Dep. - Milan University
  7. Message-ID: <4gsi42$rbp@tic.sm.dsi.unimi.it>
  8. References: <312D4B94.7957@hkein.school.net.hk>
  9. NNTP-Posting-Host: tac.fddi.dsi.unimi.it
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. K. W. Kwok (kwkwok5@hkein.school.net.hk) wrote:
  13. > Hello everybody:
  14. > Can you tell me that how to write a
  15. > header file ? I want to link a external
  16. > subprogram (a set functions)with a main 
  17. > program. They stored in different file (*.cpp).
  18. > Can I include a header file in main program to
  19. > call this subprogram ? If yes, how to do it ?
  20. > Can you slove my problems ?
  21. > Thank you very much!
  22.  
  23. > You can reply me by e-mail directly.
  24. > My e-mail address is kwkwok5@hkein.school.net.hk
  25. > Thanks!
  26.  
  27. > Bye
  28. > Wing
  29. have U tried to make this :
  30.  
  31. ----main.c----
  32. #include <stdio.h>
  33. #include <stdlib.h>
  34. #include <what_do_U_need>
  35.  
  36. extern void Subprogram1(argument_list);
  37. extern void Subprogram2(argument_list);
  38.  
  39. main(int argc, char **argv)
  40. { int a;
  41.   char c;
  42.  
  43.   ...
  44.   Subprogram1(argument_list);
  45.   ...
  46.   Subprogram2(argument_list);
  47.   ...
  48.  
  49. };
  50. ---end main.c---
  51.  
  52. ---Subprogram2.c---
  53. #include <stdio.h>
  54. #include <stdlib.h>
  55. #include <what_do_U_need>
  56.  
  57. void Subprogram1(argument_list)
  58. {
  59.   [code]
  60. };
  61.  
  62. ---end Subprogram2.c---
  63.  
  64. Idem for Subprogram1
  65.  
  66. gcc -o main.o -c main.c
  67. gcc -o Subprogram2.o -c Subprogram2.c
  68. gcc -o Subprogram1.o -c Subprogram1.c
  69. gcc -o pippo main.o Subprogram1.o Subprogram2.o
  70.  
  71. this (if I have no make kistake) work for gnu cc. If U use Borland C++ create a project and
  72. make the 3 files in the project files and It works in the same way.
  73.  
  74.  
  75.  
  76. --
  77. Zio Budda "sempre alla ricerca di un account..." moreld@ghost.dsi.unimi.it
  78. http://www.dsi.unimi.it/Users/Students/moreld/home.html
  79. Ask me for questions about LINUX and Games for PC, and see my home page 
  80. I'm a programmer and a consultant...
  81.  
  82. Tel. 02/2139959 ... Chiedere di Davide Michel
  83.